﻿namespace NTLib.Pipe.Containers
{
    using NTLib.Core.Pool;
    using NTLib.Pipe.Exceptions;
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Runtime.CompilerServices;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;

    /// <summary>
    ///  Class used to give only access to the pipe in push and send
    /// </summary>
    /// <typeparam name="T"></typeparam>
    internal class PushOnlyPipe<T> : BasePipeRelay<T>
    {
        #region Ctor

        /// <summary>
        /// Initializes a new instance of the <see cref="PushOnlyPipe{T}"/> class.
        /// </summary>
        public PushOnlyPipe()
        {
            base.PipeType = PipeType.OneWay;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Pop an item from the item's queue if the pipe permits it.
        /// </summary>
        /// <param name="token">Token used to cancel the task of waiting item.</param>
        /// <returns>
        /// Asynchronious task that wait there is an item in the pipe.
        /// </returns>
        /// <exception cref="PipeActionNotPermitsException">PopAsync</exception>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override Task<T> PopAsync(CancellationToken token = default(CancellationToken))
        {
            throw new PipeActionNotPermitsException(PipeType.OneWay, "PopAsync");
        }

        #endregion
    }
}
